import request from '@/utils/request';

/**
 * getInstanceList
 * @param data 
 * @returns 
 */
export const getInstanceList = (data) => {
  return request('/yst-workflow/workflow/api/procInst/search', {
    method: 'post',
    query: data
  });
};

/**
 * getDefinitionById
 * @param id 
 * @returns 
 */
export const getDefinitionById = (id) => {
  return request(`/yst-workflow/workflow/api/procDef/${id}`, {
    method: 'get'
  });
};

/**
 * saveDefinition
 * @param data 
 * @returns 
 */
export const saveDefinition = (data) => {
  return request('/yst-workflow/workflow/api/procDef', {
    method: 'post',
    query: data
  });
};

/**
 * deleteDefinition
 * @param id 
 * @returns 
 */
export const deleteDefinition = (id) => {
  return request(`/yst-workflow/workflow/api/category/${id}`, {
    method: 'delete'
  });
};

/**
 * getCategoryDropDownList
 * @returns 
 */
export const getCategoryDropDownList = () => {
  return request(`/yst-workflow/workflow/api/query/categorys`, {
    method: 'get'
  });
};

/**
 * getProcessHistoryList
 * @param data 
 * @returns 
 */
export const getProcessHistoryList = (data) => {
  return request(`/yst-workflow/workflow/api/taskInst/search`, {
    method: 'post',
    query: data
  });
};

/**
 * deployProcess
 * @param id 
 * @returns 
 */
export const deployProcess = (id) => {
  return request(`/yst-workflow/workflow/api/deploy/${id}`, {
    method: 'post'
  });
};

/**
 * hangOrActiveProcess
 * @param data 
 * @returns 
 */
export const hangOrActiveProcess = (data) => {
  return request(`/yst-workflow/workflow/api/activateProcessInstance`, {
    method: 'post',
    query: data
  });
};

/**
 * interupProcess
 * @param data 
 * @returns 
 */
export const interupProcess = (data) => {
  return request(`/yst-workflow/workflow/api/interruptProcessInstance`, {
    method: 'post',
    query: data
  });
};

/**
 * changeTaskAssigness
 * @param data 
 * @returns 
 */
export const changeTaskAssigness = (data) => {
  return request(`/yst-workflow/workflow/api/changeTaskAssigness`, {
    method: 'post',
    query: data
  });
};

/**
 * complete
 * @param data 
 * @returns 
 */
export const complete = (data) => {
  return request(`/yst-workflow/workflow/api/complete`, {
    method: 'post',
    query: data
  });
};

/**
 * getWorkflowUser
 * @returns 
 */
export const getWorkflowUser = () => {
  return request(`/yst-workflow/workflow/api/query/users`, {
    method: 'get'
  });
};
